<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('config')) {
            Schema::create('config', function (Blueprint $table) {
                $table->increments('id')->comment('主键ID');
                $table->string('key', 32)->default('')->comment('配置key');
                $table->string('content', 256)->default('')->comment('配置内容');
                $table->datetime('created_at')->nullable()->useCurrent()->comment('创建时间');
                $table->datetime('updated_at')->nullable()->useCurrent()->useCurrentOnUpdate()->comment('更新时间');
                $table->datetime('deleted_at')->nullable()->comment('删除时间');
            });
            DB::statement(sprintf("ALTER TABLE `%s%s` comment '%s'", config('database.connections.mysql.prefix'), 'config', '配置表'));
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('config');
    }
};
